package base;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import lombok.Data;
import util.GsonUtil;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.List;
import java.util.Set;

/**
 * @author Yangzhenyu06
 * @date 2021/8/17 2:43 下午
 */
public class FileTestV2 {

    // 仅筛已取消, toStatus=4
    public static void main(String[] args) throws IOException {
        BufferedReader msgBr =new BufferedReader(new FileReader("/Users/yzy/Meituan_File/message_2.txt"));
        BufferedReader idsBr =new BufferedReader(new FileReader("/Users/yzy/Meituan_File/orders0813.txt"));


        Set<String> orderIdSet = Sets.newHashSet();
        String orderId = "";
        while((orderId = idsBr.readLine()) != null){
            orderIdSet.add(orderId);
        }

        List<String> msgList = Lists.newArrayList();
        List<Message> msgObjList = Lists.newArrayList();
        String msg = "";
        while((msg = msgBr.readLine()) != null){
            msgList.add(msg);
            Message msgObj = GsonUtil.fromJson(msg, Message.class);
            if(orderIdSet.contains(String.valueOf(msgObj.getOrderId())) && msgObj.getToStatus()==4){
                System.out.println(msg);
            }
        }

//        System.out.println(msgList.size());
//        System.out.println(orderIdList.size());
//        System.out.println(GsonUtil.toJson(msgList));
    }


    @Data
    private static class Message{
        private long orderId;
        private int fromStatus;
        private int toStatus;
    }
}
